package org.example.strategypatterndemo.Factory;

import org.example.strategypatterndemo.module1.service.PromotionStrategy;

/**
 * Client
 * @author dingchen
 * @version 2025/05/29 17:17
**/
// 客户端代码
public class Client {
    public static void main(String[] args) {
        double orderAmount = 300;

        // 使用打折策略
        PromotionStrategy discountStrategy = PromotionStrategyFactory.getPromotionStrategy("DISCOUNT");
        if (discountStrategy != null) {
            double discount = discountStrategy.calculateDiscount(orderAmount);
            System.out.println("使用打折策略，优惠金额：" + discount);
        }

        // 使用满减策略
        PromotionStrategy fullReduceStrategy = PromotionStrategyFactory.getPromotionStrategy("FULL_REDUCE");
        if (fullReduceStrategy != null) {
            double discount = fullReduceStrategy.calculateDiscount(orderAmount);
            System.out.println("使用满减策略，优惠金额：" + discount);
        }

        // 使用赠品策略
        PromotionStrategy giftStrategy = PromotionStrategyFactory.getPromotionStrategy("GIFT");
        if (giftStrategy != null) {
            double discount = giftStrategy.calculateDiscount(orderAmount);
            System.out.println("使用赠品策略，优惠金额：" + discount);
        }
    }
}
